<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="wangyuguo">
<title>站级系统管理</title>
<script type="text/javascript" src="../script/common.js"></script>

<script type="text/javascript">
	//全局变量
	var qt = null;//数据表格对象
	
	function load() {
		Eui.showNavigation();
		setPages(["editview","listview","detview"]);
		createTable()
	}
	
	/**查询部分**/
	//创建queryTable
	function createTable() {
		var columns = []
		columns[0] = {type:"checkbox"}
		columns[8] = {title:"操作",width:"15",render:operFunc,align:"center",order:false}
		qt = new QueryTable("sel_eps", "searchForm", "datalist", columns, {
			buttons:[
				{value:"批量增加EPS",actions:onBatch},
				{value:"增加EPS",actions:onNew},
				{value:"删 除",actions:onDelete}
			]
		});
	}
	
	//操作
	function operFunc(v, r) {
		return "<a href='#' onclick=\"onEdit(" + r[0] + ");return false;\">编辑</a>";
	}
	
	//编辑EPS数据
	function onEdit(id) {
		if (id != null){
			 DWR.call("epsService.getEps",id,function(result){
				var eps = result.eps
				eps.stationName = result.stationName
				Common.setValues(epsform,eps);
				epsform.savebt.onclick = onEditSave
				switchPage('editview');
				$('selOrgSpan').innerHTML = "";
			});
		}
	}
	
	//数据删除方法
	function onDelete() {
		var ids = qt.getBoxValue();
		Eui.onDel("epsService.deleteEps",ids, "Eps", null, function() {
			qt.showTable();
		});
	}
	function onBatch(){
		epsform.reset();
		var html = "";
		html += "<button onclick='selectOrg();'>选择机构</button>";
		$('selOrgSpan').innerHTML= html;
		$("labelorg").innerHTML = "机构名称";
		switchPage('editview');
	}
	//显示新增界面
	function onNew() {
		epsform.reset();
		var html = "";
		html += "<button onclick='selOrgStation();'>选择油站</button>";
		$('selOrgSpan').innerHTML= html;
		$("labelorg").innerHTML = "加油站";
		switchPage('editview');
	}
	
	function onCancel(){
		epsform.reset();
		switchPage("listview");
	}
	function refresh(){
		showInformation("EPS保存成功！");
		epsform.reset();
		switchPage("listview");
		qt.showTable();
	}
	function onEditSave(v){
		if(!checkForm(epsform))return;
		var eps = Common.getValues(epsform);
		DWR.call("epsService.saveEps",eps,refresh,{blockScreen:true});
	}
	function onBatchSave(){
		if(!checkForm(epsform))return;
		var eps = Common.getValues(epsform);
		var orgId = eps.station;
		DWR.call("epsService.createEpsByOrg",eps,orgId,refresh,{blockScreen:true});
	}
	function selectOrg() {
		SystemMgnt.selOrgList(function(v){
			epsform.savebt.onclick = onBatchSave
			epsform.station.value = v.id
			epsform.stationName.value = v.name
		},{selOne:true,rangeLevel:Constants.ORG_LEVEL_CITY});
	}
	function selOrgStation(){
		SystemMgnt.selStation(function(v){
			epsform.savebt.onclick = onEditSave
			epsform.station.value = v.id
			epsform.stationName.value = v.name
		},{usePage:"eps_manage",selOne:true})
	}
	
	function setStationName(v){
		if (!v) return;
		searchForm.station.value = v;
		searchForm.stationName.value = v.name;
	}
</script>
</head>
<body onload="load()">
<!--页面导航-->
<div class="nav">
<div id="nav">&nbsp;</div>
</div>

<!--查询&列表-->
<div id="listview"><!--查询form-->
<div class="searchForm">
<form id="searchForm" name="searchForm">
<input type="hidden" name="station">
<table cellSpacing="0" cellPadding="4" width="100%" border="0">
	<tr>
		<td><label>加油站名称</label> <input type="text" name="stationName" maxlength="20">
			<a class="orga" href="#" onclick="SystemMgnt.selStation(setStationName,{selOne:true});">&nbsp;&nbsp;</a>
		</td>
		<td>&nbsp;&nbsp;</td>
		<td>&nbsp;&nbsp;</td>
		<td>
			<button type="button" onclick="qt.showTable()">查 询</button>
		</td>
	</tr>
</table>
</form>
</div>

<div id="datalist"></div>
</div>

<!--增加/编辑明细页面部分-->
<div id="editview" style="display: none;">
<form id="epsform" name="epsform">
	<input type="hidden" name="id">
	<input type="hidden" name="station">
<div class="form">
<div class="formTitle">编辑项目信息</div>
<table cellSpacing="0" cellPadding="4" width="100%" border="0"
	class="col2 label6">
	<tr>
		<td id="stationNameTD"><label id="labelorg">加油站</label> 
				<input readonly class="readonly" type="text" name="stationName" maxlength="20" onblur="checkV(this,'',true)">
			<span class="des">*</span><span id="selOrgSpan"></span>
		</td>
		<td valign="top" id="selectStationTd">
			<!-- label>状态</label> <input type="text" name="status" -->
		</td>
	</tr>
	<tr>
		<td><label>签到开始时间</label> <input type="text" name="beginLoginTime" onblur="checkV(this,'time',true);"> <font color="red">提示:时间格式为 23:59:59</font><span class="des">*</span></td>
		<td><label>交易上传时间</label> <input type="text" name="uploadTxTime" onblur="checkV(this,'time',true);"> <font color="red">提示:时间格式为 23:59:59</font><span class="des">*</span></td>
	</tr>
	<tr>
		<td><label>EPS管理密码</label> <input type="password" name="adminPwd" onblur="checkV(this,'',true);"> <span class="des">*</span></td>
		<td><label>EAI文件路径</label> <input type="text" name="filePath" onblur="checkV(this,'EAIPath',true);"> <span class="des">*</span></td>
	</tr>
</table>
</div>
<div align="center">
<button type="button" name="savebt" onclick="onEditSave()">保 存</button>
<button type="button" onclick="onCancel()">取 消</button>
</div>
</form>
</div>
<!--明细页面部分-->
<div id="detview" style="display: none;"></div>

</body>
</html>